package com.gitee.wsl.ext.array

import com.gitee.wsl.ext.base.Arrays

fun <V> Array<V>.swap(from: Int, to: Int) = Arrays.swap(this, from, to)

fun BooleanArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun ByteArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun CharArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun ShortArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun IntArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun LongArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun FloatArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun DoubleArray.swap(lIndex: Int, rIndex: Int) { val temp = this[lIndex]; this[lIndex] = this[rIndex]; this[rIndex] = temp }

fun <V> Array<V>.reverse(from: Int, to: Int) = Arrays.reverse(this, from, to)
